import { get, post } from "@/utils/http";

// API 常量
export const Api = {
  WhitelistTypes: "/login-whitelist/types",
  AddWhitelist: "/login-whitelist",
  RemoveWhitelist: "/login-whitelist/:id/remove",
} as const;

// 白名单类型数据类型
export interface WhitelistTypeRecord {
  [key: string]: string;
}

// 白名单数据类型
export interface WhitelistRecord {
  id?: string;
  content: string;
  type: number;
  remark: string;
}

// 获取白名单类型
export function getWhitelistTypeRecord(): Promise<{
  code: number;
  data: WhitelistTypeRecord[];
  message?: string;
}> {
  return get(Api.WhitelistTypes);
}

// 创建白名单
export function createWhitelistRecord(params: WhitelistRecord): Promise<{
  data: null;
}> {
  return post(Api.AddWhitelist, params);
}

// 删除白名单类型
export function removeWhitelistRecord(whitelistId: string): Promise<{
  code: number;
  data: null;
}> {
  return post(Api.RemoveWhitelist.replace(":id", whitelistId));
}
